<!DOCTYPE html>
	<html lang="en">
	<head>
		<meta charset="UTF-8">
		<meta name="viewport" content="width=device-width,initial-scale=1.0">
		<title>Document</title>
		<link rel="stylesheet" type="text/css" href="../css/i-club.css">
	</head>
	<body>
	<form action="">
		<div class="select">
			<div>
				<div class="center select-t">
					<p>发布项目</p>
					<img src="../img/cancel.png" class="close">
				</div>
				<div class="select-b">
					<p>提示：发布项目即扣除10美金</p>
					<div class="flex top-up-box">
						<p>支付金额：<span>￥310</span></p>
						<div class="top-up"><a href="">去充值</a></div>
					</div>
					<div class="sure center"><input type="submit" id="submit" name="" value="确定发布"></div>
				</div>
			</div>
		</div>
		<header>
			<a href="javascript:history.back(-1)" class="back"><img src="../img/back.png" height="18px"></a>
			<div class="center title">推拿会所</div>
		</header>
		<main>
			<div class="upload">
				<p>上传项目照片</p>
				<div class="flex upload_photo clearfix">
					<div class="add">+<input type="file" id="file" name="" multiple></div>
				</div>
			</div>
			<div class="item">
				<div class="flex">
					<p>项目名称：</p>
					<input type="text" name="">
				</div>
				<div class="flex">
					<p>项目介绍：</p>
					<textarea></textarea>
				</div>
				<div class="flex money">
					<div class="flex">
						<p>项目价格：</p>
						<input type="text" name="">
					</div>
					<div class="flex">
						<p>项目价格：</p>
						<input type="text" name="">
					</div>
					<div class="flex">
						<p>置顶时长：</p>
						<input type="text" name="">
					</div>
					<div class="flex">
						<p>置顶费用：</p>
						<p>300美金</p>
					</div>
				</div>
			</div>
		</main>

		<div class="parting-line"></div>
		<div class="fabu center">立刻发布</div>

	</form>
		<script src="../js/jquery-3.3.1.js"></script>
		<script src="../js/i-party.js"></script>
	</body>
</html>
<script>
	var arr=[];
	$("#file").change(function() {
		//获取图片信息
		var fileLise = $(this)[0].files;
		var fileLength = fileLise.length;
		//然后循环 生成html 插入页面上 最后就赋值给img
		for (var i = 0; i < fileLength; i++) {
			var imgDiv = '<div class="imgDiv" style="width: 60px;height: 60px;display: inline-block;border: none;margin:0 15px;"><img style="width: 100%;height: 100%" id="img' + fileLise[i].name + '"></div>';
			$(".upload_photo").append(imgDiv);
			var imgName = document.getElementById("img" + fileLise[i].name);
			// var imgurl=window.URL.createObjectURL(fileLise[i]);
			if (fileLise && fileLise[i]) {
				var file = new FileReader();
				file.readAsDataURL(fileLise[i]);
				file.onload = function() {
					console.log(this);
					imgName.src = this.result;
				}
				arr.push($(this)[i].files[0]);
			}

			if(arr.length>=3){
				$('.add').hide();
			}else {
				$('.add').show();
			}
		}
	});
	$(document).on("click", ".imgDiv", function() {
		var index=$(this).index();
		arr.splice(index-1,1);
		$(this).remove();
		if(arr.length<3){
			$('.add').show();
		}
	});
	$('#submit').click(function () {

		console.log(arr);
		return false;
	});
</script>
